package com.kgc.sbt.listener;

import com.kgc.sbt.util.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

/**
 * Created on 2021-06-19.
 * <p>
 * Author: zhukang
 * <p>
 * Description: 监听创建订单消息队列
 */
@Component
@Slf4j
public class TradeOrderListener {

    @Autowired
    private RedisUtils redisUtils;

    /**
     * @author : zhukang
     * @date : 2021-06-19
     * @return :
     * @description : 指定消息队列，获取生成订单请求
     */
    @JmsListener(destination = "buy-limit-create-order-queue")
    public void createTradeOrderFromQueue(String tradeOrderNo){
        log.info("====== 开始生成订单， 订单号{} ======", tradeOrderNo);

        // TODO 生成订单逻辑

        // 生成订单成功，从redis中将订单删除
        redisUtils.del(tradeOrderNo);
    }
}
